#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;

const int N = 1e4 + 10;
int a[N], b[N], g[N], k[N];
int n;

int find(int x, int y)
{
	for (int i = n; i >= 1; i--)
		if (x >= a[i] && y >= b[i] && x <= g[i] + a[i] && y <= k[i] + b[i])
			return i;
	return -1;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> g[i] >> k[i];
	int m, n;
	cin >> m >> n;
	cout << find(m, n);

	return 0;
}